//
//  ServiceDetailsTableViewCell.m
//  afn
//
//  Created by mac on 2018/5/9.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "ServiceDetailsTableViewCell.h"

@implementation ServiceDetailsTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)creatView1{
    HairdresserModel *model=[HairdresserModel mj_objectWithKeyValues:_model.hairdresser];
    self.backgroundColor=_LightGrey;
    UIView *beiJingView=[UIView new];
    [self addSubview:beiJingView];
    [beiJingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.bottom.mas_equalTo(-7);
    }];
    beiJingView.backgroundColor=[UIColor whiteColor];
    
    UIImageView *imageView=[UIImageView new];
    [beiJingView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(15);
        make.width.mas_equalTo(90);
        make.height.mas_equalTo(60);
    }];
    imageView.backgroundColor=_backgroundColor;
    imageView.layer.cornerRadius=4;
    imageView.layer.masksToBounds=YES;
    NSString *url=model.pic_url;
    [imageView sd_setImageWithURL:[NSURL URLWithString:url]];
    
    UILabel *label=[UILabel new];
    [beiJingView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imageView.mas_right).mas_equalTo(10);
        make.top.mas_equalTo(imageView).mas_equalTo(3);
    }];
    [label layoutIfNeeded];
    label.text=[NSString stringWithFormat:@"[%@]",model.hairdresser_category_name];
    label.textColor=[UIColor orangeColor];
    label.font=[UIFont systemFontOfSize:14];
    
    UILabel *shopNameLabel=[UILabel new];
    [beiJingView addSubview:shopNameLabel];
    [shopNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(label.mas_right).mas_equalTo(7);
        make.centerY.mas_equalTo(label);
        make.right.mas_equalTo(-10);
    }];
    shopNameLabel.textColor=ColorWithRGB(29, 29, 29);
    shopNameLabel.font=[UIFont systemFontOfSize:17];
    shopNameLabel.text=model.hairdresser_name;
    
    UILabel *priceLabel=[UILabel new];
    [beiJingView addSubview:priceLabel];
    [priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(label);
        make.bottom.mas_equalTo(imageView).mas_equalTo(0);
    }];
    priceLabel.text=[NSString stringWithFormat:@"¥ %@",model.favorable_Price];
    priceLabel.textColor=_backgroundColor;
    priceLabel.font=[UIFont systemFontOfSize:18];
    
    UILabel *VIPLabel=[UILabel new];
    [beiJingView addSubview:VIPLabel];
    [VIPLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(priceLabel.mas_right).mas_equalTo(15);
        make.bottom.mas_equalTo(priceLabel);
        make.width.mas_equalTo(30);
        make.height.mas_equalTo(20);
    }];
    VIPLabel.text=@"VIP";
    VIPLabel.font=[UIFont systemFontOfSize:14];
    VIPLabel.textColor=[UIColor whiteColor];
    VIPLabel.backgroundColor=_backgroundColor;
    VIPLabel.textAlignment=NSTextAlignmentCenter;
    CGSize size=[gongju getNSStringWeight:[NSString stringWithFormat:@"¥%@",model.sale_price] andViewWight:20 andFont:13];
    UILabel *priceLabel2=[UILabel new];
    [beiJingView addSubview:priceLabel2];
    [priceLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(VIPLabel.mas_right);
        make.height.top.mas_equalTo(VIPLabel);
        make.width.mas_equalTo(size.width+16);
    }];
    priceLabel2.textColor=_backgroundColor;
    priceLabel2.font=[UIFont systemFontOfSize:14];
    priceLabel2.text=[NSString stringWithFormat:@"¥%@",model.sale_price];
    priceLabel2.layer.borderColor=_backgroundColor.CGColor;
    priceLabel2.layer.borderWidth=1;
    priceLabel2.textAlignment=NSTextAlignmentCenter;
    
    UIView *xianView=[UIView new];
    [beiJingView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(imageView.mas_bottom).mas_equalTo(15);
        make.right.mas_equalTo(-10);
        make.height.mas_equalTo(1);
    }];
    xianView.backgroundColor=_LightGrey;
    
    UIImageView *tuBiaoImage=[UIImageView new];
    [beiJingView addSubview:tuBiaoImage];
    [tuBiaoImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(xianView.mas_bottom).mas_equalTo(15);
        make.width.height.mas_equalTo(17);
    }];
    tuBiaoImage.image=[UIImage imageNamed:@"ico-shuoming"];
    
    UILabel *tiShiLabel=[UILabel new];
    [beiJingView addSubview:tiShiLabel];
    [tiShiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(tuBiaoImage.mas_right).mas_equalTo(5);
        make.centerY.mas_equalTo(tuBiaoImage);
    }];
    tiShiLabel.text=@"支持随时退款";
    tiShiLabel.font=[UIFont systemFontOfSize:14];
    tiShiLabel.textColor=ColorWithRGB(149, 149, 149);
    
    
    UIImageView *tuBiaoImage2=[UIImageView new];
    [beiJingView addSubview:tuBiaoImage2];
    [tuBiaoImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(tiShiLabel.mas_right).mas_equalTo(20);
        make.top.mas_equalTo(xianView.mas_bottom).mas_equalTo(15);
        make.width.height.mas_equalTo(17);
    }];
    tuBiaoImage2.image=[UIImage imageNamed:@"ico-shuoming"];
    
    UILabel *tiShiLabel2=[UILabel new];
    [beiJingView addSubview:tiShiLabel2];
    [tiShiLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(tuBiaoImage2.mas_right).mas_equalTo(5);
        make.centerY.mas_equalTo(tuBiaoImage);
    }];
    tiShiLabel2.text=@"过期自动退款";
    tiShiLabel2.font=[UIFont systemFontOfSize:14];
    tiShiLabel2.textColor=ColorWithRGB(149, 149, 149);
    
    UILabel *yiShouLabel=[UILabel new];
    [beiJingView addSubview:yiShouLabel];
    [yiShouLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(tuBiaoImage);
    }];
    yiShouLabel.textColor=ColorWithRGB(99, 99, 99);
    yiShouLabel.text=[NSString stringWithFormat:@"已售%@份",model.quantity];
    yiShouLabel.font=[UIFont systemFontOfSize:14];
}
-(void)creatView3{
    HairdresserModel *model=[HairdresserModel mj_objectWithKeyValues:_model.hairdresser];
    self.backgroundColor=_LightGrey;
    UIView *beiJingView=[UIView new];
    [self addSubview:beiJingView];
    [beiJingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.bottom.mas_equalTo(-7);
    }];
    beiJingView.backgroundColor=[UIColor whiteColor];
    
    UIView *bottomView=[UIView new];
    [beiJingView addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(70);
    }];
    
    UIImageView *weiZhi=[UIImageView new];
    [bottomView addSubview:weiZhi];
    [weiZhi mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(15);
    }];
    weiZhi.image=[UIImage imageNamed:@"ico-map"];
    
    UILabel *addLabel=[UILabel new];
    [bottomView addSubview:addLabel];
    [addLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weiZhi.mas_right).mas_equalTo(6);
        make.bottom.mas_equalTo(weiZhi.mas_centerY).mas_equalTo(-3);
        make.right.mas_equalTo(-70);
    }];
    addLabel.text=model.address;
    addLabel.textColor=ColorWithRGB(49, 49, 49);
    addLabel.font=[UIFont systemFontOfSize:14];
    
    UILabel *juLiLabel=[UILabel new];
    [bottomView addSubview:juLiLabel];
    [juLiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(addLabel);
        make.right.mas_equalTo(addLabel);
        make.top.mas_equalTo(weiZhi.mas_centerY).mas_equalTo(3);
    }];
    juLiLabel.text=@"距离您45KM";
    juLiLabel.textColor=ColorWithRGB(149, 149, 149);
    juLiLabel.font=[UIFont systemFontOfSize:12];
    
    
    
    UIButton *phoneBtn=[UIButton new];
    [bottomView addSubview:phoneBtn];
    [phoneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(weiZhi);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(50);
    }];
    [phoneBtn setImage:[UIImage imageNamed:@"ico-dianhua"] forState:0];
    
    UIView *xianView=[UIView new];
    [bottomView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(phoneBtn.mas_left).mas_equalTo(-8);
        make.centerY.mas_equalTo(0);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(1);
    }];
    xianView.backgroundColor=_LightGrey;
    
  
}
-(CGFloat)creatView4{
    self.backgroundColor=_LightGrey;
    UIView *beijiView=[UIView new];
    [self addSubview:beijiView];
    [beijiView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.bottom.mas_equalTo(-7);
    }];
    beijiView.backgroundColor=[UIColor whiteColor];
    
    UIImageView *tuijina=[UIImageView new];
    [beijiView addSubview:tuijina];
    [tuijina mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
        make.width.height.mas_equalTo(20);
    }];
    tuijina.image=[UIImage imageNamed:@"ico-fuwu"];
    
    UILabel *tuiJinaLabel=[UILabel new];
    [beijiView addSubview:tuiJinaLabel];
    [tuiJinaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(tuijina.mas_right).mas_equalTo(8);
        make.centerY.mas_equalTo(tuijina);
        make.right.mas_equalTo(-10);
    }];
    tuiJinaLabel.text=[NSString stringWithFormat:@"商家服务"];
    tuiJinaLabel.textColor=ColorWithRGB(29, 29, 29);
    tuiJinaLabel.font=[UIFont systemFontOfSize:15];
    

    
    int y=(int)_model.shop_service.count/4;
    int x=(int)_model.shop_service.count%4;
    if (x>0) {
        y+=1;
    }
    int index=0;
    
    for (int i=0; i<y; i++) {
        for (int j=0; j<4; j++) {
            ServiceModel *model=[ServiceModel mj_objectWithKeyValues:_model.shop_service[index]];
      
            
            UIButton *btn=[UIButton new];
            [beijiView addSubview:btn];
            [btn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(10+(_mainW-20)/4*j);
                make.width.mas_equalTo((_mainW-35)/4);
                make.top.mas_equalTo(tuijina.mas_bottom).mas_equalTo(10+40*i);
                make.height.mas_equalTo(30);
            }];
            NSString *url=model.service_url;
            [btn.imageView sd_setImageWithURL:[NSURL URLWithString:url]];
            [btn setTitle:model.service_name forState:0];
            [btn setTitleColor:[UIColor blackColor] forState:0];
            btn.titleLabel.font=[UIFont systemFontOfSize:14];
            btn.titleLabel.textAlignment=NSTextAlignmentRight;
            if (index==_model.shop_service.count-1) {
                return 50+40*y;
            }
            index+=1;
        }
    }
    return 40;
}
-(CGFloat)creatView5{
    self.backgroundColor=_LightGrey;
    UIView *beijiView=[UIView new];
    [self addSubview:beijiView];
    [beijiView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    beijiView.backgroundColor=[UIColor whiteColor];
    
    UILabel *label=[UILabel new];
    [beijiView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
    }];
    label.text=@"服务说明";
    label.textColor=_backgroundColor;
    label.font=[UIFont systemFontOfSize:16];
    [label layoutIfNeeded];
    
    UILabel *label2=[UILabel new];
    [beijiView addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(label.mas_bottom).mas_equalTo(15);
        make.right.mas_equalTo(-10);
    }];
    label2.numberOfLines=0;
    label2.text=@"*本商品采用全息高端洗发水，按摩时长达20分钟";
    label2.textColor=ColorWithRGB(149, 149, 149);
    label2.font=[UIFont systemFontOfSize:13];
    [label2 layoutIfNeeded];
    
    UILabel *label3=[UILabel new];
    [beijiView addSubview:label3];
    [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(label2.mas_bottom).mas_equalTo(7);
        make.right.mas_equalTo(-10);
    }];
    label3.numberOfLines=0;
    label3.text=@"*如果头发长度超过50cm，会加收30%费用";
    label3.textColor=ColorWithRGB(149, 149, 149);
    label3.font=[UIFont systemFontOfSize:13];
    [label3 layoutIfNeeded];
    
    
    UILabel *label4=[UILabel new];
    [beijiView addSubview:label4];
    [label4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(label3.mas_bottom).mas_equalTo(15);
    }];
    label4.text=@"购买须知";
    label4.textColor=_backgroundColor;
    label4.font=[UIFont systemFontOfSize:16];
    [label4 layoutIfNeeded];

    UILabel *label5=[UILabel new];
    [beijiView addSubview:label5];
    [label5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(label4.mas_bottom).mas_equalTo(15);
    }];
    label5.text=@"预约信息";
    label5.textColor=ColorWithRGB(49, 49, 49);
    label5.font=[UIFont systemFontOfSize:14.5];
    [label5 layoutIfNeeded];
    
    UILabel *label6=[UILabel new];
    [beijiView addSubview:label6];
    [label6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(label5.mas_bottom).mas_equalTo(10);
    }];
    label6.numberOfLines=0;
    label6.text=@"∙ 请您提前2小时预约";
    label6.textColor=ColorWithRGB(149, 149, 149);
    label6.font=[UIFont systemFontOfSize:14.5];
    [label6 layoutIfNeeded];
    
    UILabel *label7=[UILabel new];
    [beijiView addSubview:label7];
    [label7 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(label6.mas_bottom).mas_equalTo(15);
    }];
    label7.text=@"适用人数";
    label7.textColor=ColorWithRGB(49, 49, 49);
    label7.font=[UIFont systemFontOfSize:14.5];
    [label7 layoutIfNeeded];
    
    UILabel *label8=[UILabel new];
    [beijiView addSubview:label8];
    [label8 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(label7.mas_bottom).mas_equalTo(10);
    }];
    label8.text=@"∙ 每张团购券最多1人使用";
    label8.numberOfLines=0;
    label8.textColor=ColorWithRGB(149, 149, 149);
    label8.font=[UIFont systemFontOfSize:14.5];
    [label8 layoutIfNeeded];
    
    
    UILabel *label9=[UILabel new];
    [beijiView addSubview:label9];
    [label9 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(label8.mas_bottom).mas_equalTo(15);
    }];
    label9.text=@"规则提醒";
    label9.textColor=ColorWithRGB(49, 49, 49);
    label9.font=[UIFont systemFontOfSize:14.5];
    [label9 layoutIfNeeded];
    
    UILabel *label10=[UILabel new];
    [beijiView addSubview:label10];
    [label10 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(label9.mas_bottom).mas_equalTo(10);
    }];
    label10.text=@"∙ 如需团购券发票，请您在消费时向商家咨询";
    label10.numberOfLines=0;
    label10.textColor=ColorWithRGB(149, 149, 149);
    label10.font=[UIFont systemFontOfSize:14.5];
    [label10 layoutIfNeeded];
 
  
    
    return 10+label.frame.size.height+15+label2.frame.size.height+7+label3.frame.size.height+15+label4.frame.size.height+15+label5.frame.size.height+10+label6.frame.size.height+15+label7.frame.size.height+10+label8.frame.size.height+15+label9.frame.size.height+10+label10.frame.size.height+20;
}

@end
